package com.demo.afternoon;

/**
 * @ClassName 反射
 * @Description TODO
 * @Author tianqinglong
 * @Date 19:08 2022/7/12
 * @Version 1.0
 **/
public class 反射 {
    public static void main(String[] args) throws ClassNotFoundException {
        Student student = new Student();
        Class<? extends Student> aClass = student.getClass();
        System.out.println(aClass.hashCode());
        Class<?> aClass1 = Class.forName("com.demo.afternoon.Student");
        System.out.println(aClass1.hashCode());
        Class<Student> studentClass = Student.class;
        System.out.println(studentClass.hashCode());

        Class<Integer> type = Integer.TYPE;
        System.out.println(type); //int

        Class<?> superclass = aClass.getSuperclass();
        System.out.println(superclass); //class com.demo.afternoon.Person
    }
}


class Person {
    public String name;

    public Person() {
    }

    public Person(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person [name=" + name + "]";
    }

}

class Student extends Person {
    public Student() {
        this.name = "学生";
    }
}

class Teacher extends Person {
    public Teacher() {
        this.name = "老师";
    }
}
